<?php
 
 class Chanel_Model_FollowChanel extends Zend_Db_Table
 {
 	protected $_name="followchanel";
    protected $_primary = 'id';
    
 	public function insertFollow($arrParam = null, $option = null)
  	{	  		  		
  		$row = $this->fetchNew();		  	
		$row->follower       = @$arrParam['follower'];
		$row->followed       = @$arrParam['followed'];			
		$row->createdate       =@$arrParam['createdate'];				
	  	return $row->save();
	  	
  	}
  	public function countFollow($idchanel){
  		$db = Zend_Registry::get('connectDB');
  		$count = $db->fetchOne("SELECT COUNT(*) AS count FROM followchanel where followed = '".$idchanel."'");
  		
  		return $count;
  	}
  	
 	public function ischeckFollow($chanelid,$userid){
		
		$db = Zend_Registry::get('connectDB');
  		$count = $db->fetchOne("SELECT COUNT(*) AS count FROM followchanel WHERE followed='".$chanelid."' and follower = '".$userid."'" );
  		
  		return $count;
		
	}
	
 	public function listChanelByFollowed($chanelid){
		
		$db = Zend_Registry::get('connectDB');
				
  		$sql = "select DISTINCT follower,followed from followchanel where followed= '".$chanelid."'";
  		$result = $db->fetchAll($sql);
		
  		return $result;
  	}
  	
 }
 
 ?>